From: Owen W. Taylor Date: Tue, 23 Sep 2014 15:58:27 +0000 (-0400) Subject: ostree admin: Fix return value from 'ostree admin [instutil]' X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~1111 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=40f490ed11febb72182b125c67a86b5f634211b6;p=ostree.git ostree admin: Fix return value from 'ostree admin [instutil]' 'ostree admin' and 'ostree admin instuil' with no arguments were meant to fail, but the logic was wrong; add an assertion on the return value from all ostree commands to catch similar problems in the future. https://bugzilla.gnome.org/show_bug.cgi?id=737194 --- diff --git a/src/ostree/ot-admin-builtin-instutil.c b/src/ostree/ot-admin-builtin-instutil.c index 0a6bb315..66ea80ed 100644 --- a/src/ostree/ot-admin-builtin-instutil.c +++ b/src/ostree/ot-admin-builtin-instutil.c @@ -127,7 +127,13 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCance g_print (" %s\n", subcommand->name); subcommand++; } - return subcommand_name == NULL ? 1 : 0; + + if (want_help) + ret = TRUE; + else + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "No command specified"); + goto out; } subcommand = admin_instutil_subcommands; diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c index f7dce93a..6db97ca4 100644 --- a/src/ostree/ot-builtin-admin.c +++ b/src/ostree/ot-builtin-admin.c @@ -155,7 +155,13 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can g_print (" %s\n", subcommand->name); subcommand++; } - return subcommand_name == NULL ? 1 : 0; + + if (want_help) + ret = TRUE; + else + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "No command specified"); + goto out; } subcommand = admin_subcommands; diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 1dfa93d7..6adb2d22 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -83,6 +83,7 @@ ostree_run (int argc, const char *repo_arg = NULL; gboolean want_help = FALSE; gboolean skip; + gboolean success = FALSE; int in, out, i; /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */ @@ -191,7 +192,11 @@ ostree_run (int argc, if (cmd == NULL) { - if (!want_help) + if (want_help) + { + success = TRUE; + } + else { g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED, "No command specified"); @@ -252,7 +257,10 @@ ostree_run (int argc, if (!command->fn (argc, argv, repo, cancellable, &error)) goto out; + success = TRUE; out: + g_assert (success || error); + if (error) { g_propagate_error (res_error, error);